package com.example.restaurant.controller.component;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import com.example.restaurant.dao.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Component
public class PermissionResolver implements StpInterface {

    @Resource
    private UserMapper userMapper;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
       log.info("查询用户权限信息：{}",loginId);
        List<String> permissions = userMapper.getPermissions((int) loginId);

        return permissions;
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
//        //loginId == userId
        log.info("查询用户角色信息：{}",loginId);

        List<String> roles = userMapper.getRole((int) loginId);

        return roles;
    }
}

